home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Gfx / Edit / TSMorph / src / TSMorph.h < prev    next >
C/C++ Source or Header  |  1994-10-30  |  29KB  |  1,064 lines

  1. // TSMorph - Amiga Morphing program
  2. // Copyright (C) © 1993  Topicsave Limited
  3.  
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; either version 2 of the License, or
  7. // any later version.
  8.  
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. // GNU General Public License for more details.
  13.  
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. // mpaddock@cix.compulink.co.uk
  19.  
  20. #ifndef TSMORPH_H
  21. #define TSMORPH_H
  22.  
  23. /* All the Amiga stuff    */
  24. #define INTUI_V36_NAMES_ONLY
  25. #define INTUITION_IOBSOLETE_H
  26. #include <exec/types.h>
  27. #include <exec/memory.h>
  28. #include <exec/execbase.h>
  29. #include <intuition/intuition.h>
  30. #include <intuition/intuitionbase.h>
  31. #include <intuition/classes.h>
  32. #include <intuition/classusr.h>
  33. #include <intuition/gadgetclass.h>
  34. #include <intuition/imageclass.h>
  35. #include <intuition/icclass.h>
  36. #include <devices/input.h>
  37. #include <workbench/workbench.h>
  38. #include <workbench/startup.h>
  39. #include <libraries/gadtools.h>
  40. #include <graphics/scale.h>
  41. #include <libraries/asl.h>
  42. #include <libraries/amigaguide.h>
  43. #include <libraries/reqtools.h>
  44. #include <libraries/dctv.h>
  45.  
  46. /* Various stuff is not defined in 2.02 headers    */
  47. #ifndef PGA_NewLook
  48. #define PGA_NewLook (PGA_Dummy + 0x000A)
  49. #endif
  50.  
  51. #ifndef GTMN_FullMenu
  52. #define GTMN_FullMenu GT_TagBase+62
  53. #endif
  54.  
  55. #ifndef WA_MenuHelp
  56. #define WA_MenuHelp (WA_Dummy + 0x2F)
  57. #endif    
  58.  
  59. #ifndef WA_NewLookMenus
  60. #define WA_NewLookMenus (WA_Dummy + 0x30)
  61. #endif
  62.  
  63. #ifndef GTMN_NewLookMenus
  64. #define GTMN_NewLookMenus GT_TagBase+67
  65. #endif
  66.  
  67. #ifndef STRINGA_ExitHelp
  68. #define STRINGA_ExitHelp (STRINGA_Dummy + 0x0013)
  69. #endif
  70.  
  71. #ifndef GT_Underscore
  72. #define GT_Underscore GT_TagBase+64
  73. #endif
  74.  
  75. #ifndef IDCMP_GADGETHELP
  76. #define IDCMP_GADGETHELP 0x04000000
  77. #endif
  78.  
  79. #if INCLUDE_VERSION < 39
  80. void HelpControl(struct Window *w,ULONG flags);
  81. #pragma libcall IntuitionBase HelpControl 33C 0802
  82. void SetRGB32( struct ViewPort *vp, unsigned long n, unsigned long r, unsigned long g,unsigned long b);
  83. #pragma libcall GfxBase SetRGB32 354 3210805
  84. void GetRGB32( struct ColorMap *cm, unsigned long firstcolor,unsigned long ncolors, ULONG *table);
  85. #pragma libcall GfxBase GetRGB32 384 910804
  86. #endif
  87.  
  88. #ifndef HC_GADGETHELP
  89. #define HC_GADGETHELP 1
  90. #endif
  91.  
  92. #ifndef SA_Interleaved
  93. #define SA_Interleaved (SA_Dummy + 0x0022)
  94. #endif
  95.  
  96. /* prototypes    */
  97. #include <clib/exec_protos.h>
  98. #include <clib/dos_protos.h>
  99. #include <clib/layers_protos.h>
  100. #include <clib/graphics_protos.h>
  101. #include <clib/intuition_protos.h>
  102. #include <clib/input_protos.h>
  103. #include <clib/gadtools_protos.h>
  104. #include <clib/asl_protos.h>
  105. #include <clib/utility_protos.h>
  106. #include <clib/diskfont_protos.h>
  107. #include <clib/icon_protos.h>
  108. #include <clib/amigaguide_protos.h>
  109. #define LIBRARIES_MATHFFP_H    // Do not include other math stuff
  110. #include <clib/alib_protos.h>
  111. #include <clib/reqtools_protos.h>
  112. #include <clib/dctv_protos.h>
  113.  
  114. /* Pragmas    */
  115. #include <pragmas/exec_pragmas.h>
  116. #include <pragmas/dos_pragmas.h>
  117. #include <pragmas/layers_pragmas.h>
  118. #include <pragmas/graphics_pragmas.h>
  119. #include <pragmas/intuition_pragmas.h>
  120. #include <pragmas/input_pragmas.h>
  121. #include <pragmas/gadtools_pragmas.h>
  122. #include <pragmas/asl_pragmas.h>
  123. #include <pragmas/utility_pragmas.h>
  124. #include <pragmas/diskfont_pragmas.h>
  125. #include <pragmas/icon_pragmas.h>
  126. #include <pragmas/amigaguide_pragmas.h>
  127. #include <pragmas/reqtools.h>
  128. #include <pragmas/dctv_pragmas.h>
  129.  
  130. #include <rexx/errors.h>
  131. #include <pragmas/rexxsyslib_pragmas.h>
  132. #include <clib/rexxsyslib_protos.h>
  133.  
  134. /* 2.02 Icon headers    */
  135. #if INCLUDE_VERSION < 37
  136. BOOL DeleteDiskObject(UBYTE *name);
  137. #pragma libcall IconBase DeleteDiskObject 8A 801
  138. #endif
  139.  
  140. /* Below is not in the 2.02 version of clib/utility_protos.h
  141.                                        pragmas/utility_pragmas.h */
  142. #if INCLUDE_VERSION < 37
  143. LONG Stricmp(UBYTE *string1,UBYTE *string2);
  144. #pragma libcall UtilityBase Stricmp A2 9802
  145. #endif
  146.  
  147. /* Standard headers    */
  148. #include <stddef.h>
  149. #include <string.h>
  150. #include <stdio.h>
  151. #include <math.h>
  152.  
  153. /* OpalVision            */
  154. #include <opal/opallib.h>
  155.  
  156. /* EGS                    */
  157. #include <egs/clib/egs_protos.h>
  158. #include <egs/pragmas/egs_pragmas.h>
  159. #include <egs/clib/egsintui_protos.h>
  160. #include <egs/pragmas/egsintui_pragmas.h>
  161. #include <egs/clib/egsgfx_protos.h>
  162. #include <egs/pragmas/egsgfx_pragmas.h>
  163. #include <egs/clib/egsrequest_protos.h>
  164. #include <egs/pragmas/egsrequest_pragmas.h>
  165. #include <egs/egsintui.h>
  166. extern struct Library *EGSIntuiBase;
  167. extern struct Library *EGSGfxBase;
  168. extern struct Library *EGSBase;
  169. extern struct Library *EGSRequestBase;
  170.  
  171. /* define max if not already defined    */
  172. #ifndef max
  173. #define max(a,b) ((a)>(b)?(a):(b))
  174. #endif
  175.  
  176. /* IFF stuff                    */
  177. #include "iffp/ILBMapp.h"
  178.  
  179. /* GUI stuff from GadTools    */
  180. #include "gui.h"
  181.  
  182. /* Message keys                */
  183. #include "Messages.h"
  184.  
  185. /* defines for the IDs of the gadgets in the control window    */
  186. #define ONEGADGET        1
  187. #define TWOGADGET        2
  188. #define RELGADGET        3
  189. #define ADDGADGET        4
  190. #define DELGADGET        5
  191. #define LINKGADGET    6
  192. #define UNLINKGADGET    7
  193. #define NONEGADGET    8
  194. #define STGADGET        9
  195. #define PREVGADGET    10
  196. #define GOTOGADGET    11
  197. #define NEXTGADGET    12
  198. #define LASTGADGET    13
  199.  
  200. /* Defined externally    */
  201. extern struct DosLibrary *DOSBase;
  202. extern struct ExecBase *SysBase;
  203.  
  204. /*    Structure definitions    */
  205.  
  206. /* Picture structure
  207.  * This holds all information for a picture displayed in a window
  208.  */
  209. struct Picture {                        // Structure used for each picture
  210.     struct Screen        *Screen;        // Screen to display on
  211.     struct Window        *Win;            // Window
  212.     struct EI_Window    *EGS_Win;    // EGS Window
  213.     struct E_EBitMap    *EGS_BitMap;//    EGS Bitmap
  214.     struct DrawInfo    *DRI;            // Draw Info
  215.     struct Gadget        *BotGad;        // Bottom slider gadget
  216.     struct Gadget        *SideGad;    // Side slider gadget
  217.     struct Gadget        *Lgad;        // Left arrow gadget
  218.     struct Gadget        *Rgad;        // Right arrow gadget
  219.     struct Gadget        *Ugad;        // Up arrow gadget
  220.     struct Gadget        *Dgad;        // Down arrow gadget
  221.     struct Image        *Limage;        // Left arrow
  222.     struct Image        *Rimage;        // Right arrow
  223.     struct Image        *Uimage;        // Up arrow
  224.     struct Image        *Dimage;        // Down arrow
  225.     UWORD                    Left;            // Left edge
  226.     UWORD                    Top;            // Top edge
  227.     UWORD                    XLeft;        // Old left edge
  228.     UWORD                    XTop;            // Old top edge
  229.     UWORD                    ALeft;        // Left movement 10% of window
  230.     UWORD                    ATop;            // down movement 10% of window
  231.     UWORD                    MLeft;        // Max left edge
  232.     UWORD                    MTop;            // Max top edge
  233.     struct ILBMInfo    *ilbm;        // ILBM info for iff read
  234.     UWORD                    currentg;    // Current gadgetID
  235.     char                    *filename;    // For Window title
  236.     ULONG                    JustSeconds;//    Time window was activated - to ignore first click
  237.     struct BitMap        BitMap;        // The zoomed image bitmap
  238.     struct BitScaleArgs BitScaleArgs;    // For zooming image
  239.     BOOL                    Opal;            // Set if opened by OpalLoad
  240.     struct {
  241.         WORD                Left;            // Window Zoom tags - nothing to do with Zoom
  242.         WORD                Top;
  243.         WORD                Width;
  244.         WORD                Height;
  245.     } Zoom;
  246.     UWORD                    width;        // both only valid when EGS
  247.     UWORD                    height;
  248. };
  249.  
  250. #define MAX_LINKS 16
  251.  
  252. /* Point structure
  253.  * Holds all information for each point
  254.  */
  255. struct MyPoint {
  256.     struct MinNode MyNode;                // Node to link in a list
  257.     WORD x,y;                                // Coordinates in the 1st image
  258.     WORD x1,y1;                                // Coordinates in the 2nd image
  259.     WORD    NumLinks;                        // Number of links on this point
  260.     struct MyPoint *p[MAX_LINKS];        // Pointers to up to MAX_LINKS linked points
  261. };
  262.  
  263. /* Structure for size of system gadgets
  264.  * based on Screen resolution
  265.  * This enables windows to open with correct
  266.  * gadgets on lo-res screens
  267.  */
  268. struct gadgetsizing {
  269.     ULONG sysisize;        // tag for SYSISIZE_???RES
  270.     int sizeimagew;
  271.     int sizeimageh;
  272.     int leftimagew;
  273.     int leftimageh;
  274.     int downimagew;
  275.     int downimageh;
  276.     int rightimagew;
  277.     int rightimageh;
  278.     int upimagew;
  279.     int upimageh;
  280.     int closeimagew;
  281.     int zoomimagew;
  282.     int depthimagew;
  283.     int vscrollw;
  284.     int vscrolll;
  285. };
  286.  
  287. /* Macro for finding gadget    */
  288. #define PointInBox(x,y,mx,my,MX,MY) ((x>=mx)&&(y>=my)&&(x<=MX)&&(y<=MY))
  289.  
  290. /* Macros to access system gadget sizes    */
  291. #define SYSISIZE(n)        gs[n].sysisize
  292. #define SIZEIMAGE_W(n)    gs[n].sizeimagew
  293. #define SIZEIMAGE_H(n)    gs[n].sizeimageh
  294. #define LEFTIMAGE_W(n)    gs[n].leftimagew
  295. #define LEFTIMAGE_H(n)    gs[n].leftimageh
  296. #define DOWNIMAGE_W(n)    gs[n].downimagew
  297. #define DOWNIMAGE_H(n)    gs[n].downimageh
  298. #define UPIMAGE_W(n)        gs[n].upimagew
  299. #define UPIMAGE_H(n)        gs[n].upimageh
  300. #define RIGHTIMAGE_W(n)    gs[n].rightimagew
  301. #define RIGHTIMAGE_H(n)    gs[n].rightimageh
  302. #define CLOSEIMAGE_W(n)    gs[n].closeimagew
  303. #define ZOOMIMAGE_W(n)    gs[n].zoomimagew
  304. #define DEPTHIMAGE_W(n)    gs[n].depthimagew
  305. #define VSCROLL_W(n)        gs[n].vscrollw
  306. #define VSCROLL_L(n)        gs[n].vscrolll
  307.  
  308. /* defines for resolution for index    */
  309. #define GS_LOWRES            0
  310. #define GS_MEDRES            1
  311.  
  312. /* Pointer image structures */
  313. extern UWORD __chip Add[];
  314. extern UWORD __chip Del[];
  315. extern UWORD __chip L1[];
  316. extern UWORD __chip L2[];
  317. extern UWORD __chip Mov[];
  318. extern UWORD __chip One[];
  319. extern UWORD __chip Rel[];
  320. extern UWORD __chip Two[];
  321. extern UWORD __chip U1[];
  322. extern UWORD __chip U2[];
  323.  
  324. /* Defines for the help system nodes
  325.  * See "help.h" for the node text
  326.  */
  327. #define H_Nothing        0
  328. #define H_Main         1
  329. #define HE_IFFBMHD    2
  330. #define HE_IFFRASTER    3
  331. #define HE_IFFBODY    4
  332. #define HE_IFFCLIP    5
  333. #define HE_IFFILBM    6
  334. #define HE_IFFFileS    7
  335. #define HE_IFFTOP        8
  336. #define HE_IFFMEM        9
  337. #define H_G24File2    10
  338. #define H_Width        11
  339. #define H_Height        12
  340. #define H_Single        13
  341. #define H_Frames        14
  342. #define H_Start        15
  343. #define H_Name            16
  344. #define H_GName        17
  345. #define H_EPoints        18
  346. #define H_IClose        19
  347. #define H_IZoom        20
  348. #define H_IDepth        21
  349. #define H_IM            22
  350. #define H_IMP            23
  351. #define H_IMS            24
  352. #define H_IMPO            25
  353. #define H_IMPS            26
  354. #define H_IMPSA        27
  355. #define H_IMPA            28
  356. #define H_IMPQ            29
  357. #define H_IMPE            30
  358. #define H_P_KS            31
  359. #define H_CWindow        32
  360. #define H_EOne            33
  361. #define H_ETwo            34
  362. #define H_ERel            35
  363. #define H_EAdd            36
  364. #define H_EDel            37
  365. #define H_ELnk            38
  366. #define H_EUnl            39
  367. #define H_EMov            40
  368. #define H_CClose        41
  369. #define H_CDepth        42
  370. #define H_CM            43
  371. #define H_CMP            44
  372. #define H_CMS            45
  373. #define H_CMPO            46
  374. #define H_CMPS            47
  375. #define H_CMPSA        48
  376. #define H_CMPA            49
  377. #define H_CMPE            50
  378. #define H_CMPQ            51
  379. #define H_P_LOADS        52
  380. #define H_CMSM            53
  381. #define H_EWindow        54
  382. #define H_Horiz        55
  383. #define H_Vert            56
  384. #define H_Up            57
  385. #define H_Down            58
  386. #define H_Left            59
  387. #define H_Right        60
  388. #define H_EClose        61
  389. #define H_EZoom        62
  390. #define H_EDepth        63
  391. #define H_ESize        64
  392. #define H_P_SAVES        65
  393. #define H_P_SAVESAS    66
  394. #define H_CME            67
  395. #define H_CMEG            68
  396. #define H_RAG            69
  397. #define H_RAGGX        70
  398. #define H_RAGGY        71
  399. #define H_RAGGOK        72
  400. #define H_RAGGCA        73
  401. #define H_RAGGCL        74
  402. #define H_RAGGDE        75
  403. #define H_IMPN            76
  404. #define H_CMPN            77
  405. #define HE_Size        78
  406. #define HE_OGrid        79
  407. #define HE_Grid0        80
  408. #define HE_MPoints    81
  409. #define H_IWindow        82
  410. #define H_FileOne        83
  411. #define H_GFileOne    84
  412. #define H_FileTwo        85
  413. #define H_GFileTwo    86
  414. #define H_24File1        87
  415. #define H_G24File1    88
  416. #define H_24File2        89
  417. #define HE_OMorph        90
  418. #define HE_Screen        91
  419. #define HE_Library    92
  420. #define HE_FileReq    93
  421. #define HE_WPort        94
  422. #define HE_IDevice    95
  423. #define HE_ISmall        96
  424. #define HE_IDifferent    97
  425. #define HE_ZRaster    98
  426. #define HE_Menu        99
  427. #define HE_OWindow    100
  428. #define HE_MemFile    101
  429. #define HE_AllocGadget    102
  430. #define HE_AllocImage    103
  431. #define HE_LoadImage    104
  432. #define HE_AllocIFF    105
  433. #define HE_AllocILBM    106
  434. #define HE_GetDRI        107
  435. #define HE_LockScreen    108
  436. #define HE_FileFormat    109
  437. #define HE_TooSmall    110
  438. #define HE_Range        111
  439. #define HE_MemPoints    112
  440. #define HE_InvLink    113
  441. #define HE_Close        114
  442. #define HE_Open        115
  443. #define HE_Write        116
  444. #define HE_4points    117
  445. #define HE_NotLinked    118
  446. #define HE_LinkSelf    119
  447. #define HE_Linked        120
  448. #define HE_UnlinkSelf    121
  449. #define HE_MemNewPoint    122
  450. #define H_Unsaved        123
  451. #define HE_OldFormat    124
  452. #define HC_First        125
  453. #define HC_Previous    126
  454. #define HC_Goto        127
  455. #define HC_Next        128
  456. #define HC_Last        129
  457. #define H_CMEF            130
  458. #define H_CMEFF        131
  459. #define H_CMEFP        132
  460. #define H_CMEFG        133
  461. #define H_CMEFN        134
  462. #define H_CMEFL        135
  463. #define HE_OneFrame    136
  464. #define HE_FAllSize    137
  465. #define H_IMPD            138
  466. #define H_FrameNumber    139
  467. #define H_P_CP            140
  468. #define H_P_CI            141
  469. #define H_P_CIP        142
  470. #define H_P_OM            143
  471. #define H_P_PS            144
  472. #define H_P_ZO            145
  473. #define H_P_CIR        146
  474. #define H_P_DE            147
  475. #define H_P_DX            148
  476. #define H_P_DY            149
  477. #define H_P_LS            150
  478. #define H_P_MO            151
  479. #define H_P_POS        152
  480. #define H_P_PES        153
  481. #define H_P_PSR        154
  482. #define H_P_QU            155
  483. #define H_P_SF            156
  484. #define H_S_RD            157
  485. #define H_S_LS            158
  486. #define H_S_R            159
  487. #define HE_SaveSettings    160
  488. #define HE_LoadSettings    161
  489. #define HE_OpalVision    162
  490. #define HE_AllocPlanes    163
  491. #define HE_NoOpal        164
  492. #define H_P_AA            165
  493. #define HE_NoFile        166
  494. #define H_P_HE            167
  495. #define H_HelpGad        168
  496. #define H_P_Preview    169
  497. #define H_IMPP            170
  498. #define H_CMPP            171
  499. #define H_Arexx        172
  500. #define H_PCUSTM        173
  501. #define H_PCUSTD        174
  502. #define HE_OScreen    175
  503. #define HE_DrawI        176
  504. #define HE_LockW        177
  505. #define HE_ScreenMode    178
  506. #define H_P_INT        179
  507. #define HE_CScreen    180
  508. #define H_CMET            181
  509.  
  510. /* Defines for the Disabled Messages */
  511. #define DI_Zoom        1000
  512. #define DI_WaitSS        1001
  513. #define DI_WaitOpen    1002
  514. #define DI_WaitSave    1003
  515. #define DI_Delete        1004
  516. #define DI_About        1005
  517. #define DI_Image1        1006
  518. #define DI_Image2        1007
  519. #define DI_Draw        1008
  520. #define DI_Grid        1009
  521. #define DI_Unsaved    1010
  522. #define DI_Preview    1011
  523. #define DI_LoadBrush    1012
  524. #define DI_New            1013
  525. #define DI_GetFrame    1014
  526. #define DI_NextFrame    1015
  527. #define DI_Triangulate    1016
  528.  
  529. /* TSMorph.c    */
  530.  
  531. /* Libraries    */
  532. extern struct IntuitionBase *IntuitionBase;
  533. extern struct Library    *GfxBase,
  534.                     *LayersBase,
  535.                     *InputBase,
  536.                     *IFFParseBase,
  537.                     *GadToolsBase,
  538.                     *AslBase,
  539.                     *UtilityBase,
  540.                     *DiskfontBase,
  541.                     *AmigaGuideBase,
  542.                     *IconBase,
  543.                     *ReqToolsBase,
  544.                     *RexxSysBase,
  545.                     *DCTVBase;
  546.  
  547. extern struct OpalBase *OpalBase;
  548.  
  549. /* Externals defined    */
  550. extern struct gadgetsizing        gs[];            /* Size of system gadgets        */
  551. extern UWORD                         Mode;            /* Current editing mode            */
  552. extern struct List                PointList;    /* List of Points                    */
  553. extern struct Picture             Pic1,            /* 1st                                */
  554.                                         Pic2;            /* and 2nd images                    */
  555. extern BOOL                            Pic1_Open;    /* If 1st                            */
  556. extern BOOL                            Pic2_Open;    /* and 2nd images are open        */
  557. extern struct FileRequester    *filereq;    /* General use file requester    */
  558. extern struct rtFileRequester    *rtfilereq;    /* General use rt file requester            */
  559. extern BOOL                            Saved;        /* Set to FALSE after editing    */
  560. extern char                            savedfilename[256];    /* Current project file name    */
  561. extern LONG                            Width,        /* Width and                        */
  562.                                         Height;        /* Height of project                */
  563. extern LONG                            SinglePicture;    /* TRUE for Warps                */
  564. extern BOOL                            Zoom;                /* TRUE if current Zoomed    */
  565. extern BOOL                            ZoomAllowed;    /* FALSE to save memory        */
  566. extern BOOL                            PaletteAllowed;    /* FALSE for compatibility            */
  567. extern char                            **ArgArray;            /* Parameter/ToolTypes                */
  568. extern char                            **ArgArraySettings;/* From settings file                */
  569. extern AMIGAGUIDECONTEXT        handle;        /* Help handle                        */
  570. extern BOOL                            palette;        /* TRUE if Palette changed        */
  571. extern BOOL                            CreateIcons;/* TRUE if to write Icons        */
  572. extern BOOL                            CreateIconsR;/* TRUE if to write Render Icons    */
  573. extern BOOL                            CreateIconsP;/* TRUE if to write prefs Icons    */
  574. extern BOOL                            KeepSettings;/* TRUE to save settings on quit */
  575. extern ULONG                        DX;
  576. extern ULONG                        DY;
  577. extern char                            LoadScript[];
  578. extern char                            PreScript[];
  579. extern char                            PostScript[];
  580. extern char                            ScreenName[];
  581. extern char                            ScreenNameR[];
  582. extern char                            PreviewScript[];
  583. extern char                            CustomName[];
  584. extern ULONG                        CustomDepth;
  585. extern BOOL                            OpenedScreen;
  586. extern ULONG                        Depth;
  587. extern ULONG                        RenderMode;
  588. extern ULONG                        SaveFormat;
  589. extern ULONG                        Quality;
  590. extern ULONG                        ASig;            /* Amiga guide signal            */
  591. extern ULONG                        OpenMode;    /* Open mode (opal etc.)        */
  592. extern int                            changedboxcount;    // Used to redraw points after resizing BOTH windows
  593. extern UWORD                        n;                    // Holds screen resolution
  594. extern LONG                         MaxWidth;        // Max x of points
  595. extern LONG                            MaxHeight;        // Max y of points
  596. extern BOOL                            AntiAlias;        // Anti Alias?
  597. extern BOOL                            Integer;            // Integer calculation?
  598. extern BOOL                            GHelp;            // Gadget Help?
  599. extern struct NewAmigaGuide    nag;                // .guide stuff
  600. extern BOOL                            EGS;                // Use EGS picture window
  601.  
  602. extern UBYTE                        *message[];    // Messages
  603.  
  604. /* Properties for IFF read    */
  605. extern LONG props[];
  606. extern LONG stops[];
  607. extern LONG nowt[];
  608. extern LONG FrameNumber;
  609. extern USHORT __chip BusyPointerData[];
  610.  
  611. /* Prototypes    */
  612. void About(void);
  613. int main(int argc,char **argv);
  614. BOOL openAPicture(char *filename,struct Picture *Pic,BOOL Gui);
  615. void CloseAPicture(struct Picture *pic);
  616. void doNewSize(struct Picture *pic);
  617. void checkGadget(struct Picture *pic);
  618. void DrawPixels(struct Picture *pic,SHORT x,SHORT y,struct MyPoint *MyPoint);
  619. void DeleteAllPoints(void);
  620. BOOL MyOpen(char *filename,BOOL JustPoints,BOOL Gui);
  621. BOOL SaveAs(char *filename);
  622. void MySetMode(UWORD NewMode);
  623. void doMsgLoop(void);
  624. void SetMyPointer(void);
  625. int DoMenu(struct Picture *pic,UWORD Selection);
  626. void DisableWindows(ULONG dnum);
  627. void EnableWindows(void);
  628. void Vanilla(ULONG code);
  629. void MouseButtons(struct Picture *pic,ULONG code,ULONG seconds);
  630. void MouseMove(struct Picture *pic);
  631.  
  632. /* Defines for Image movement gadgets IDS    */
  633. #define NO_GADGET                (0)
  634. #define UP_DOWN_GADGET        (1)
  635. #define LEFT_RIGHT_GADGET    (2)
  636. #define UP_GADGET                (3)
  637. #define DOWN_GADGET            (4)
  638. #define LEFT_GADGET            (5)
  639. #define RIGHT_GADGET            (6)
  640.  
  641. /* Defines for Edit mode    */
  642. #define EDIT1        1    // moving points in one window
  643. #define EDIT2        2    // moving points in both windows absolutely
  644. #define EDITREL    3    // moving points in both windows relatively
  645. #define ADD            4    // Adding points
  646. #define DELETE        5    // Deleting points
  647. #define LINK1        6    // Linking points - select 1st point
  648. #define UNLINK1    7    // Unlinkg points
  649. #define LINK2        8    // Linking points - select 2nd point
  650. #define LINK2A        9    // Linking points - 2nd point selected
  651. #define UNLINK2    10    // Unlinking points - select 2nd point
  652. #define UNLINK2A    11    // Unlinking points - 2n point selected
  653. #define NONE        12    // Just scrolling the windows
  654.  
  655. /* Defines for menu items    */
  656. #define M_PROJECT            0    // Project menu
  657.  
  658. #define MM_NEW                0
  659. #define MM_OPEN            1
  660. #define MM_B1                2
  661. #define MM_SAVE            3
  662. #define MM_SAVEAS            4
  663. #define MM_B2                5
  664. #define MM_ABOUT            6
  665. #define MM_B3                7
  666. #define MM_EXITPOINTS    8
  667. #define MM_B4                9
  668. #define MM_QUIT            10
  669. #define MM_B5                11
  670. #define MM_PPREVIEW        12
  671.  
  672. #define M_EDIT                1    // Edit menu
  673.  
  674. #define MM_GRID            0
  675. #define MM_TRIANGULATE    1
  676. #define MM_FRAME            2    // Frame sub-menu
  677.  
  678. #define MI_FIRST            0
  679. #define MI_PREV            1
  680. #define MI_GOTO            2
  681. #define MI_NEXT            3
  682. #define MI_LAST            4
  683.  
  684. #define MM_MODE            3    // Mode sub-menu
  685.  
  686. #define MI_EDITONE        0
  687. #define MI_EDITTWO        1
  688. #define MI_EDITREL        2
  689. #define MI_ADD                3
  690. #define MI_DELETE            4
  691. #define MI_LINK            5
  692. #define MI_UNLINK            6
  693. #define MI_NONE            7
  694.  
  695. #define M_SETTINGS        2    // Settings menu
  696.  
  697. #define MM_ICONS            0
  698. #define MM_PALETTE        1
  699. #define MM_ZOOM            2
  700. #define MM_OPENMODE        3
  701.  
  702. #define MI_ALWAYS            0
  703. #define MI_IFILBM            1
  704. #define MI_IFCOLOURS        2
  705. #define MI_REMAP            3
  706. #define MI_OPAL            4
  707.  
  708. #define MM_SCREEN            4
  709. #define MM_CUSTOM            5
  710. #define MM_CDEPTH            6
  711. #define MM_SPREVIEW        7
  712.  
  713. #define MM_C1                8
  714. #define MM_ICONSP            9
  715. #define MM_KEEPS            10
  716. #define MM_LOADS            11
  717. #define MM_SAVES            12
  718. #define MM_SAVESAS        13
  719. #define MM_C2                14
  720. #define MM_ICONSR            15
  721. #define MM_DX                16
  722. #define MM_DY                17
  723. #define MM_LOADSCRIPT    18
  724. #define MM_PRESCRIPT        19
  725. #define MM_POSTSCRIPT    20
  726. #define MM_DEPTH            21
  727. #define MM_RENDERMODE    22
  728.  
  729. #define MI_MODE1            0
  730. #define MI_MODE2            1
  731. #define MI_MODE4            2
  732. #define MI_MODE8            3
  733. #define MI_MODE16            4
  734.  
  735. #define MM_SAVEFORMAT    23
  736.  
  737. #define MI_ILBM24            0
  738. #define MI_OPAL24            1
  739. #define MI_OPAL24T        2
  740. #define MI_OPAL24F        3
  741. #define MI_OPAL24FT        4
  742. #define MI_JPEG            5
  743. #define MI_JPEGT            6
  744. #define MI_PBM                7
  745. #define MI_BW16            8
  746. #define MI_BW256            9
  747. #define MI_HAM6            10
  748. #define MI_HAM8            11
  749. #define MI_DCTV3            12
  750. #define MI_DCTV4            13
  751.  
  752. #define MM_QUALITY        24
  753. #define MM_SCREENR        25
  754. #define MM_ANTIALIAS        26
  755. #define MM_INTEGER        27
  756. #define MM_C3                28
  757. #define MM_RESETD            29
  758. #define MM_LASTS            30
  759. #define MM_RESTORE        31
  760. #define MM_C4                32
  761. #define MM_HELP            33
  762.  
  763. #define OPEN_ILBM_IF_ILBM        MI_IFILBM        // Open using iffparse if an ilbm <24 bits
  764. #define OPEN_ILBM_IF_COLOURS    MI_IFCOLOURS    // Open using iffparse if less colours than screen
  765. #define OPEN_ILBM_ALWAYS        MI_ALWAYS        // Open using iffparse only
  766. #define OPEN_REMAP                MI_REMAP            // Remap if possible
  767. #define OPEN_OPAL                    MI_OPAL            // Always use opal.library and remap
  768.  
  769. /* Subroutines.c    */
  770.  
  771. extern char TempFilename[256];        // File name used to get a file name
  772.  
  773. /* Prototypes    */
  774. void ihelp(ULONG helpnum);
  775. void help(ULONG helpnum);
  776. void ColorWindow(struct Picture *pic);
  777. void UnColorWindow(struct Picture *pic);
  778. void MyArgArrayInit(int argc,char **argv);
  779. void MyArgArrayDone(void);
  780. UBYTE *MyArgString(UBYTE *arg2,UBYTE *arg3,BOOL reopen);
  781. LONG MyArgInt(UBYTE *arg2, long arg3,BOOL reopen);
  782. BOOL MyFindToolType(UBYTE *arg2,BOOL reopen);
  783. void OpenNewArgs(UBYTE *filename);
  784. void CloseWindowSafely(struct Window *win);
  785. void StripIntuiMessages(struct MsgPort *mp,struct Window *win);
  786. void Error(char *ErrorMessage,char *Gadget,char *extra,ULONG helpnum);
  787. void XError(struct Picture *pic,char *ErrorMessage,char *Gadget,char *extra,ULONG helpnum);
  788. void DrawAllPoints(void);
  789. void OpenPointsEdit(void);
  790. void AddGrid(void);
  791. void ReallyAddGrid(void);
  792. void DoMenuHelp(USHORT code);
  793. BOOL SaveRequester(void);
  794. void LinkPoints(struct MyPoint* MyPoint,struct MyPoint *MyPoint1);
  795. void UnlinkPoints(struct MyPoint* MyPoint,struct MyPoint *MyPoint1,BOOL Draw);
  796. void UnlinkAllPoints(BOOL Draw);
  797. struct MyPoint *FindPoint(struct Picture *pic,WORD x,WORD y);
  798. VOID DeletePoint(struct MyPoint* MyPoint);
  799. void MyDraw(struct RastPort *rp, SHORT x, SHORT y, SHORT oldx, SHORT oldy);
  800. void EGSMyDraw(struct EG_RastPort *rp, SHORT x, SHORT y, SHORT oldx, SHORT oldy);
  801. BOOL GetAFile(char *name,char *Prompt,ULONG flags);
  802. void LimitPoints(SHORT *x,SHORT *y,struct Picture *pic);
  803. void InitParams(BOOL firstcall);
  804. void UpdateParams(ULONG OZoom);
  805. int Preview(void);
  806. LONG SendRxMsg(char *msgtxt,BOOL IgnoreError);
  807. BOOL OpenCustomScreen(void);
  808. void CloseCustomScreen(void);
  809. void Triangulate(void);
  810. BOOL GenerateTriangles(void);
  811. int *IntVect(int ncols);
  812. void MyFreeVecti(int *vectptr);
  813. int **IntMatrix(int nrows, int ncols);
  814. void FreeMatrixi(int **matptr);
  815. double **DoubleMatrix(int nrows, int ncols);
  816. void FreeMatrixd(double **matptr);
  817.  
  818. /* Brush images    */
  819. extern struct Image Add_im;
  820. extern struct Image Del_im;
  821. extern struct Image Link_im;
  822. extern struct Image None_im;
  823. extern struct Image One_im;
  824. extern struct Image Rel_im;
  825. extern struct Image Two_im;
  826. extern struct Image Unlink_im;
  827. extern struct Image st_im;
  828. extern struct Image prev_im;
  829. extern struct Image goto_im;
  830. extern struct Image next_im;
  831. extern struct Image last_im;
  832.  
  833. extern struct Image Add_imx;
  834. extern struct Image Del_imx;
  835. extern struct Image Link_imx;
  836. extern struct Image None_imx;
  837. extern struct Image One_imx;
  838. extern struct Image Rel_imx;
  839. extern struct Image Two_imx;
  840. extern struct Image Unlink_imx;
  841. extern struct Image st_imx;
  842. extern struct Image prev_imx;
  843. extern struct Image goto_imx;
  844. extern struct Image next_imx;
  845. extern struct Image last_imx;
  846.  
  847. /* LoadBrushes.c        */
  848. int myloadbrush(struct ILBMInfo *info,UBYTE *filename);
  849. void mycopysprite(struct ILBMInfo *ilbm,UWORD *address,UBYTE *filaname);
  850. void mycopybrush(struct ILBMInfo *ilbm,struct Image *im,UBYTE *filename,UWORD size);
  851. void invertbrush(struct Image *im,UWORD size);
  852. void LoadBrushes(void);
  853.  
  854. /* ControlWindow.c    */
  855.  
  856. /* Gadgets    */
  857. extern struct Gadget OneGadget;
  858. extern struct Gadget TwoGadget;
  859. extern struct Gadget RelGadget;
  860. extern struct Gadget MyAddGadget;
  861. extern struct Gadget DelGadget;
  862. extern struct Gadget LinkGadget;
  863. extern struct Gadget UnlinkGadget;
  864. extern struct Gadget NoneGadget;
  865. extern struct Gadget stGadget;
  866. extern struct Gadget prevGadget;
  867. extern struct Gadget gotoGadget;
  868. extern struct Gadget nextGadget;
  869. extern struct Gadget lastGadget;
  870.  
  871. /* Defines for Image sizes    */
  872. #define IMAGE_WIDTH    38        /* The width of a Control Window gadget     */
  873. #define IMAGE_HEIGHT    34        /* and the Height                                    */
  874. #define AIMAGE            15        /* Arrow image size                                */
  875.  
  876. /* Defines for menu items in array */
  877. #define NM_PROJECT            0
  878. #define NM_NEWPOINTS            1
  879. #define NM_OPENPOINTS        2
  880.  
  881. #define NM_SAVE                4
  882. #define NM_SAVEAS                5
  883.  
  884. #define NM_ABOUT                7
  885.  
  886. #define NM_EXITPOINTS        9
  887.  
  888. #define NM_QUIT                11
  889.  
  890. #define NM_PPREVIEW            13
  891.  
  892. #define NM_EDIT                14
  893. #define NM_ADDGRID            15
  894. #define NM_TRIANGULATE        16
  895. #define NM_FRAME                17
  896. #define NM_FIRST                18
  897. #define NM_PREVIOUS            19
  898. #define NM_GOTO                20
  899. #define NM_NEXT                21
  900. #define NM_LAST                22
  901. #define NM_EMODE                23
  902. #define NM_M_ONE                24
  903. #define NM_M_TWO                25
  904. #define NM_M_REL                26
  905. #define NM_M_ADD                27
  906. #define NM_M_DEL                28
  907. #define NM_M_LNK                29
  908. #define NM_M_UNL                30
  909. #define NM_M_MOV                31
  910. #define NM_SETTINGS            32
  911. #define NM_CREATEICONS        33
  912. #define NM_CHANGEPALETTE    34
  913. #define NM_ZOOM                35
  914. #define NM_OPENMODE            36
  915. #define NM_ILBMALWAYS        37
  916. #define NM_ILBMIFILBM        38
  917. #define NM_ILBMIFCOLOURS    39    
  918. #define NM_REMAP                40
  919. #define NM_ILBMOPAL            41
  920. #define NM_SCREEN                42
  921. #define NM_CUSTOM                43
  922. #define NM_CDEPTH                44
  923. #define NM_SPREVIEW            45
  924.  
  925. #define NM_ICONSP                47
  926. #define NM_KEEPS                48
  927. #define NM_LOADS                49
  928. #define NM_SAVES                50
  929. #define NM_SAVESAS            51
  930.  
  931. #define NM_ICONSR                53
  932. #define NM_DX                    54
  933. #define NM_DY                    55
  934. #define NM_LOADSCRIPT        56
  935. #define NM_PRESCRIPT            57
  936. #define NM_POSTSCRIPT        58
  937. #define NM_DEPTH                59
  938. #define NM_MODE                60
  939. #define NM_MODE1                61
  940. #define NM_MODE2                62
  941. #define NM_MODE4                63
  942. #define NM_MODE8                64
  943. #define NM_MODE16                65
  944. #define NM_SAVEFORMAT        66
  945. #define NM_ILBM24                67
  946. #define NM_OPAL24                68
  947. #define NM_OPAL24T            69
  948. #define NM_OPAL24F            70
  949. #define NM_OPAL24FT            71
  950. #define NM_OPALJPEG            72
  951. #define NM_OPALJPEGT            73
  952. #define NM_PBM                    74
  953. #define NM_BW16                75
  954. #define NM_BW256                76
  955. #define NM_HAM6                77
  956. #define NM_HAM8                78
  957. #define NM_DCTV3                79
  958. #define NM_DCTV4                80
  959. #define NM_QUALITY            81
  960. #define NM_SCREENR            82
  961. #define NM_ANTIALIAS            83
  962. #define NM_INTEGER            84
  963.  
  964. #define NM_RESETD                86
  965. #define NM_LASTS                87
  966. #define NM_RESTORE            88
  967.  
  968. #define NM_HELP                90
  969.  
  970. /* Externals defined    */
  971. extern struct NewMenu MyNewMenu[];
  972. extern struct Window    *ControlWindow;
  973. extern struct Menu     *MyMenu;
  974. extern UBYTE            *CWTitle;
  975.  
  976. /* Prototypes    */
  977. struct Window *OpenControlWindow(void);
  978. void CloseControlWindow(void);
  979. void UpdateMenuDefs(void);
  980.  
  981. /* help.c */
  982. extern unsigned char *context[];
  983. extern unsigned char *ShortHelp[];
  984. extern unsigned char *disabled[];
  985.  
  986. /* Args.c    */
  987. void argArrayDone( void );
  988. char **argArrayInit( LONG argc, char **argv );
  989.  
  990. /* Frames.c    */
  991. int FirstFrame(void);
  992. int PrevFrame(void);
  993. int GotoFrame(void);
  994. int NextFrame(void);
  995. int LastFrame(void);
  996. BOOL GetFrameNumber(void);
  997. int ReopenPictures(void);
  998. BOOL ReopenAPicture(char *filename,struct Picture *pic);
  999.  
  1000. /* OpalLoad.c */
  1001.  
  1002. extern UWORD FileFormat;
  1003.  
  1004. /* recognized file formats */
  1005. #define FORMAT_IFF    1
  1006. #define FORMAT_JPEG    2
  1007. #define FORMAT_GIF    3
  1008. #define FORMAT_PPM    4
  1009. #define FORMAT_TARGA    5
  1010.  
  1011. extern struct RastPort     RP,            // Work Rast Ports
  1012.                                  TRP;
  1013. extern struct BitMap TBM;                // Temp bitmap
  1014. extern UBYTE *plane0;                    // Planes for temporary bit maps
  1015. extern UBYTE *plane1;
  1016. extern UBYTE *plane2;
  1017. extern UBYTE *plane3;
  1018. extern UBYTE *plane4;
  1019. extern UBYTE *plane5;
  1020. extern UBYTE *plane6;
  1021. extern UBYTE *plane7;
  1022. extern UBYTE *Array;
  1023.  
  1024. BOOL MyLoadBrush(struct Picture *pic,UBYTE *filename);
  1025. BOOL OpalLoad(struct Picture *pic,UBYTE *filename);
  1026. BOOL InitArray(UWORD w);
  1027. void FreeArray(void);
  1028. BOOL ChunkyToPlanar(struct Picture *pic,UWORD width,UWORD height,UBYTE *chunky);
  1029. void RGBToScreen000(UBYTE *red,UBYTE *green,UBYTE *blue,UWORD Height,UWORD Width,
  1030.                           UWORD maxcol,UWORD xadd,UBYTE *r,UBYTE *g,UBYTE *b);
  1031. BOOL PlanarToChunky(struct Picture *pic,UWORD w,UWORD h,UBYTE *r,UBYTE *g,UBYTE *b);
  1032. void PaletteToScreen000(struct RastPort *Rp,struct Picture *Pic,UWORD maxcol,
  1033.                                 UBYTE *r,UBYTE *g,UBYTE *b);
  1034. void PaletteToEGS000(struct RastPort *Rp,struct Picture *pic,UBYTE *plane,UBYTE *r,UBYTE *g,UBYTE *b);
  1035.  
  1036. /* HandleSettings.c */
  1037. void RemoveMenus(void);
  1038. void AddMenus(void);
  1039. void UpdateSaveFormat(BOOL remove);
  1040. void UpdateRenderMode(BOOL remove);
  1041. void UpdateOpenMode(BOOL remove);
  1042. void UnZoom(void);
  1043. void ReZoom(void);
  1044. void SwitchMenuItem(UWORD pos,BOOL setting,BOOL remove);
  1045. void HandleSettings(UWORD Selection,struct Picture *pic);
  1046. void GetANumber(char *title,ULONG *number,ULONG HelpNum);
  1047. void GetAString(char *title,char *buffer,ULONG HelpNum);
  1048.  
  1049. void SaveSettings(char *filename);
  1050. void LoadSettings(char *filename);
  1051.  
  1052. /* RGBToScreen020.c    */
  1053. void PaletteToScreen020(struct RastPort *Rp,struct Picture *Pic,UWORD maxcol,
  1054.                                 UBYTE *r,UBYTE *g,UBYTE *b);
  1055. void RGBToScreen020(UBYTE *red,UBYTE *green,UBYTE *blue,UWORD Height,UWORD Width,
  1056.                           UWORD maxcol,UWORD xadd,UBYTE *r,UBYTE *g,UBYTE *b);
  1057. void PaletteToEGS020(struct RastPort *Rp,struct Picture *pic,UBYTE *plane,UBYTE *r,UBYTE *g,UBYTE *b);
  1058.  
  1059. /* Messages.c */
  1060. // char *MyGetMsg(UWORD MsgNo);
  1061. #define MyGetMsg(MsgNo) message[MsgNo]
  1062.  
  1063. #endif
  1064.